package com.awenhui.demo.filter;

import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.authentication.event.InteractiveAuthenticationSuccessEvent;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * @author yuxf
 * @version 1.0
 * @date 2020/10/19 9:27
 */
public class MyUsernamePasswordAuthenticationFilter extends UsernamePasswordAuthenticationFilter {

//    /**
//     * 验证用户名密码
//     * @param request
//     * @param response
//     * @return
//     * @throws AuthenticationException
//     */
//    @Override
//    public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
//        System.out.println(">>>>>>>>"+this.getClass().getName()+"<<<<<<<<");
//       // return super.attemptAuthentication(request, response);
//        UsernamePasswordAuthenticationToken token=new UsernamePasswordAuthenticationToken("admin","123456a");
//        setDetails(request,token);
//       return this.getAuthenticationManager().authenticate(token);
//    }

}
